//
//  addcarViewController.m
//  car
//
//  Created by chenxu on 15/3/19.
//  Copyright (c) 2015年 chenxu. All rights reserved.
//

#import "addcarViewController.h"
@interface addcarViewController ()

@end

@implementation addcarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    carview = [[CarView alloc]initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height - kScreen_NavigationBarHeight) car:nil];
    [self.view addSubview:carview];
    carview.myTableView.tableFooterView = [self tableFooterView];
}

- (UIView*)tableFooterView{
    
    UIView *footerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 90)];
    UILabel * tip = [[UILabel alloc]initWithFrame:CGRectMake(30, 0, kScreen_Width-30*2, 30)];
    
    tip.text = @"您填的越精确，保险费计算的越精确";
    tip.textColor = [UIColor redColor];
    tip.textAlignment = NSTextAlignmentCenter;
    tip.font = [UIFont fontWithName:@"Helvetica" size:12];

    UIButton *saveBtn = [UIButton buttonWithStyle:StrapThemeStyle andTitle:@"保存" andFrame:CGRectMake(30, 25, kScreen_Width-30*2, 40) target:self action:@selector(savecar:)];
    [saveBtn setPopingPressed];

    [footerV addSubview:saveBtn];
    [footerV addSubview:tip];
    return footerV;
}


- (void)savecar:(id)sender{
    [carview addcar:^{
       // weakSelf.savebutton.enabled = true;
        NSInteger count = [self.navigationController.viewControllers count];
        //跳回上一页
        [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:count-3] animated:YES ];
        
    }];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

//- (IBAction)savecar:(id)sender {
//    __weak typeof(self) weakSelf = self;
//    weakSelf.savebutton.enabled = false;
//    [carview addcar:^{
//        weakSelf.savebutton.enabled = true;
//        NSInteger count = [self.navigationController.viewControllers count];
//        //跳回上一页
//        [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:count-2] animated:YES ];
//    }];
//}
@end
